import { fetchGet,fetchPost,fetchDelete,fetchPut,fetchPatch } from '../utils/http'

/**
 * 获取班级列表
 */
export const allClass = () => {
    return fetchGet("/class/allClasses")
}

/** 
 * 获取班级课程列表
*/
export const classCourseList = (params) => {
    return fetchGet("/course/byClass",{classId:params})
}

/**
 * 课程是否购买
 */
export const isBuy = (params) => {
    return fetchGet("/coin/order/isOwn",{
        objId:params.objId,
        objType:params.objType
    })
}

/**
 * 课程价格信息
 */
export const getCoursePrice = (params) => {
    return fetchGet(`/course/${params}/pay`)
}

/**
 * 课程章节列表
 */
export const getCoursePart = (params) => {
    return fetchGet(`/course/${params}/directory`)
}

/**
 * 课程简介
 */
export const getOne = (params) => {
    return fetchGet("/course/getOne",{id:Number(params)})
}

/**
 * 获取讨论列表
 */
export const getdiscussList = (params) => {
    return fetchGet("/discuss/list",{
        objId:params.objId,
        objType:params.objType
    })
}

/**
 * 添加讨论
 */
export const createDiscuss = (params) => {
    return fetchPost("/discuss/one",{
        content:params.content,
        obj_id:params.obj_id,
        obj_type:params.obj_type
    })
}

/**
* 获取笔记列表
*/
export const getNoteList = (params) => {
    return fetchGet("/note/list",{
        videoId:params.videoId
    })
}

/**
 * 新建笔记
 */
export const createNote = (params) => {
    return fetchPost("/note/create",{
        content:params.content,
        description:params.description,
        name:params.name,
        video_id:params.video_id,
        watch_point:params.watch_point
    })
}

/**
 * 删除笔记
 */
export const delNote = (params) => {
    return fetchDelete("/note/delete",{note_id:params})
}

/**
* 修改笔记内容
*/
export const modifyNote = (params) => {
    return fetchPut("/note/save",{
        content:params.content,
        description:params.description,
        name:params.name,
        note_id:params.note_id,
        video_id:params.video_id,
        watch_point:params.watch_point
    })
}

/**
 * 获取提问列表
 */
export const getAskList = (params) => {
    return fetchGet("/ask/myAsk",{courseId:params})
}

/**
 * 添加提问
 */
export const createAsk = (params) => {
    return fetchPost("/ask/addAsk",{
        allSee:params.allSee,
        content:params.content,
        courseId:params.courseId
    })
}

/**
 * 获取评论
 */
export const getCommentList = (params) => {
    return fetchGet("/comments/getComments",{
        objId:params.objId,
        objType:params.objType
    })
}

/**
 * 添加评论
 */
export const createComment = (params) => {
    return fetchPost("/comments/addComments",{
        content:params.content,
        objId:params.objId,
        objType:params.objType
    })
}

/**
 * 评论点赞
 */
export const praise = (params) => {
    return fetchPatch(`/comments/${params}/praise`)
}

/**
 * 删除评论
 */
export const delComment = (params) => {
    return fetchDelete("/comments/deleteComments",{
        commentId:params
    })
}

/**
 * 获取notebook列表
 */
export const getNotebookList = (params) => {
    return fetchGet("/resource/tasklist",{
        dataId:params.dataId,
        type:params.type
    })
}

/**
 * 创建notebook
 */
export const createNotebook = (params) => {
    return fetchPost("/notebook/create",{
        from_type:params.from_type,
        name:params.name,
        foreign_id:params.foreign_id
    })
}

/**
 * 删除notebook
 */
export const delNotebook = (params) => {
    return fetchDelete("/notebook/delete",{
        notebook_id:Number(params.notebook_id),
        type:params.type
    })
}